package sms

import (
	"errors"
)

var (
	SmsURL                 = "http://yunpian.com/v1/sms/tpl_send.json"
	ValidPhoneNumberLength = 11
	ResponseError          = errors.New("Response error")
)

type PhoneNumber string

type InvalidPhoneNumberError struct {
	PhoneNumber string
}

func (e InvalidPhoneNumberError) Error() string { return "Invalid Phone number:" + e.PhoneNumber }

func (s PhoneNumber) Valid() bool {
	if len(s) != ValidPhoneNumberLength {
		return false
	}
	for _, letter := range s {
		if !(letter >= '0' && letter <= '9') {
			return false
		}
	}
	return true
}

type SmsService interface {
	Send(PhoneNumber, string) error
}
